<template>
  <div class="shop">
    <!-- 头部 -->
    <div class="shop-head clearfix">
      <i class="iconfont icon-arrow-left-bold" @click="$router.back()"></i>
      <div class="shop-head-content clearfix">
        <div class="shop-logo"></div>
        <div class="shop-name" @click="showCoverShopInfo = true">
          <span class="brand">品牌</span>
          <span class="name">方中山胡辣汤 (总店)</span>
          <div class="arrow"></div>
        </div>
        <div class="shop-data">
          <span class="shop-data-detail">4.2</span>
          <span class="shop-data-detail">月售 90 单</span>
          <span class="shop-data-detail">饱了么专送 约 28 分钟</span>
          <span class="shop-data-detail">距离 1000m</span>
        </div>
        <div class="shop-activities" @click="showCoverShopAcitivity = true">
          <span class="mini-tag green">首单</span>
          <span class="activity-content ellipsis"
            >新用户下单立减17元(不与其它活动同享)</span
          >
          <span class="acticity-num">8个优惠</span>
        </div>
      </div>
    </div>

    <!-- 三个选项卡 -->
    <div class="shop-tab">
      <router-link to="/shop/goods" replace>点餐</router-link>
      <router-link to="/shop/comment" replace>评价</router-link>
      <router-link to="/shop/info" replace>商家</router-link>
    </div>

    <!-- 页内路由,对应三个选项卡 -->
    <keep-alive>
      <router-view></router-view>
    </keep-alive>

    <!-- 商家信息遮罩层 -->
    <transition name="fade">
      <CoverShopInfo
        v-show="showCoverShopInfo"
        @closeCoverShopInfo="closeCoverShopInfo"
      ></CoverShopInfo>
    </transition>

    <!-- 商家活动遮罩层 -->
    <transition name="scroll">
      <CoverShopAcitivity
        v-show="showCoverShopAcitivity"
        @closeCoverShopAcitivity="closeCoverShopAcitivity"
      ></CoverShopAcitivity>
    </transition>
  </div>
</template>

<script>
import CoverShopInfo from "../../components/CompsOfShop/CoverShopInfo.vue"
import CoverShopAcitivity from "../../components/CompsOfShop/CoverShopAcitivity.vue"
import { mapActions, mapState } from "vuex"

export default {
  name: "Shop",
  data() {
    return {
      showCoverShopInfo: false,
      showCoverShopAcitivity: false,
    }
  },
  computed: {
    ...mapState(["goods", "comments", "cartFoods"]),
  },
  methods: {
    ...mapActions(["getShopGoods", "getShopComments"]),
    closeCoverShopInfo() {
      this.showCoverShopInfo = false
    },
    closeCoverShopAcitivity() {
      this.showCoverShopAcitivity = false
    },
  },
  mounted() {
    this.getShopGoods()
    this.getShopComments()
  },
  components: {
    CoverShopInfo,
    CoverShopAcitivity,
  },
}
</script>

<style lang="less" scoped>
@import "../../common/style/mixin.less";
.shop {
  position: relative;
  height: 100vh;

  //  firefox中隐藏滚动条
  scrollbar-width: none;
  // chrome中隐藏滚动条
  &::-webkit-scrollbar {
    width: 0;
  }
}
.shop-head {
  position: relative;
  width: 100%;
  background-image: url("https://fuss10.elemecdn.com/f/5c/ead54394c3de198d3e6d3e9111bbfpng.png");
  background-size: contain;
  .icon-arrow-left-bold {
    position: absolute;
    top: 1.3rem;
    left: 0.5rem;
    font-size: 2rem;
    color: #fff;
  }
  .shop-head-content {
    margin-top: 5rem;
    background-color: #fff;
    .shop-logo {
      position: absolute;
      top: 1rem;
      left: 50%;
      transform: translateX(-50%);
      width: 6.6rem;
      height: 6.6rem;
      border-radius: 0.2rem;
      background-image: url(https://fuss10.elemecdn.com/8/40/02872ce8aefe75c16d3190e75ad61jpeg.jpeg);
      background-size: contain;
      box-shadow: 0.1rem 0.1rem 0.1rem rgba(0, 0, 0, 0.2);
    }
    .shop-name {
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top: 3.2rem;
      .brand {
        width: 3.6rem;
        height: 1.8rem;
        line-height: 1.8rem;
        font-size: 1.2rem;
        font-weight: 600;
        color: #6a3709;
        background-color: #ffe337;
        border-radius: 0.2rem;
        text-align: center;
        margin-right: 1rem;
      }
      .name {
        width: 20rem;
        height: 2.4rem;
        font-size: 2rem;
        color: #333333;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .arrow {
        width: 0.5rem;
        height: 0.5rem;
        //这里必须加一个Border:solid,才会出现border
        border: solid;
        border-width: 0.5rem 0 0.5rem 0.7rem;
        border-color: transparent transparent transparent rgba(0, 0, 0, 0.67);
      }
    }
    .shop-data {
      line-height: 1;
      margin-top: 0.3rem;
      text-align: center;
      .shop-data-detail {
        margin: 0 0.4rem;
        font-size: 1.1rem;
        color: #333;
      }
    }
    .shop-activities {
      display: flex;
      align-items: center;
      width: 31.5rem;
      height: 2.5rem;
      margin: 0.5rem auto 0;
      padding: 0 0.7rem;
      border-radius: 0.1rem;
      border: 0.1rem solid #eee;
      span {
        color: #666;
        font-size: 1.1rem;
        &.mini-tag {
          height: 1.4rem;
          line-height: 1.2rem;
          font-size: 1rem;
          text-align: center;
          padding: 0.1rem 0.2rem;
          margin-right: 0.5rem;
          font-weight: bold;
        }
        &.acticity-num {
          display: flex;
          align-items: center;
          margin-left: 2rem;
          &::after {
            content: "";
            border: solid;
            margin-left: 0.5rem;
            border-width: 0.5rem 0.4rem 0 0.4rem;
            border-color: #6e6e6e transparent transparent transparent;
          }
        }
      }
    }
  }
}
.shop-tab {
  .bottom-border-1px(#e6e7e8);
  display: flex;
  height: 4rem;
  line-height: 4rem;
  text-align: center;
  background-color: #fff;
  a {
    position: relative;
    flex: 1;
    height: 100%;
    color: #7e8c8d;
    font-size: 1.4rem;
    transition: 0.2s;
    &::after {
      content: "";
      position: absolute;
      z-index: 1;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
      height: 0.2rem;
      width: 0;
      background-color: @theme-color;
      transition: 0.2s;
    }
    &.router-link-active {
      color: @theme-color;
      &::after {
        width: 5rem;
      }
    }
  }
}

.fade-enter-active,
.fade-leave-active {
  transition: 0.4s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}

.scroll-enter-active,
.scroll-leave-active {
  transition: 0.4s;
}
.scroll-enter,
.scroll-leave-to {
  transform: translateY(24rem);
}

.green {
  color: #fff !important;
  background-color: #70bc46 !important;
}
.red {
  color: #fff !important;
  background-color: #ee6060 !important;
}
.orange {
  color: #fff !important;
  background-color: orange !important;
}
</style>
